package com.huatai.bpmn.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huatai.bpmn.entity.TbBusinessEntity;
import com.huatai.bpmn.entity.dto.BusinessDto;
import com.huatai.bpmn.service.TbBusinessService;
import com.huatai.common.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @author gusiyi
 * @version 1.0
 * @className BusinessController
 * @description 描述：
 * @date 2023/8/21 17:15
 */
@RestController
@RequestMapping("/tbBusiness")
@Api(value = "业务数据操作controller",tags = "业务数据操作controller")
public class BusinessController {

	@Autowired
	private TbBusinessService tbBusinessService;

	@GetMapping("/getTaskEchoList")
	@ApiOperation("获取业务数据（回显）下拉列表")
	public R<List<TbBusinessEntity>> getTaskEcho(@RequestParam("deployId") String deployId,@RequestParam("status") String status){
		String[] statusArr = status.split(",");
		LambdaQueryWrapper<TbBusinessEntity> businessQuery = Wrappers.lambdaQuery();
		businessQuery
			.select(TbBusinessEntity::getMatterName,TbBusinessEntity::getProcinstId)
			.eq(TbBusinessEntity::getDeleted,false)
			.eq(TbBusinessEntity::getDeployId,deployId)
			.in(TbBusinessEntity::getStatus,statusArr)
			.orderByDesc(TbBusinessEntity::getUpdateTime);
		List<TbBusinessEntity> taskEchoList = tbBusinessService.list(businessQuery);
		return R.data(taskEchoList);
	}

	@PostMapping("getBusinessList")
	@ApiOperation("项目数据统计筛选-统计表中干系人和动态表单参数")
	public  R getBusinessList(@RequestBody BusinessDto businessDto){
		List<TbBusinessEntity> list = tbBusinessService.getBusinessList(businessDto);
		return R.data(list);
	}

}
